import Vue from 'vue'
import Router from 'vue-router'



import ant_reg from '@/components/ant_reg'
import ant_login from '@/components/ant_login'
import ant_back from '@/components/ant_back'
import putuser from '@/components/putuser'
import myback from '@/components/myback'
import deluser from '@/components/deluser'
import finduser from '@/components/finduser'
import lookuser from '@/components/lookuser'
import myback_user from '@/components/myback_user'
import mylogin from '@/components/mylogin'
import myqxupdate from '@/components/myqxupdate'
import Reply from '@/components/Reply'
import mybackgong from '@/components/mybackgong'
import gongdan from '@/components/gongdan'
import gongdanadd from '@/components/gongdanadd'
import gongdanget from '@/components/gongdanget'
import qiniu from '@/components/qiniu'
import upload from '@/components/upload'

import jindu from '@/components/jindu'
import cmm from '@/components/cmm'


import axios from 'axios'
import { message } from 'ant-design-vue';
Vue.use(Router)


export default new Router({
  routes: [

    {
      path:'/cmm',  // 注册
      name:'cmm',
      component:cmm
    },

    {
      path:'/jindu',  // 注册
      name:'jindu',
      component:jindu
    },

    {
      path:'/',  // 注册
      name:'mylogin',
      component:mylogin
    },
    {
      path:'/qiniu',  // 注册
      name:'qiniu',
      component:qiniu
    },
    {
      path:'/upload',  // 注册
      name:'upload',
      component:upload
    },
    {
      path:'/reply',  // 注册
      name:'Reply',
      component:Reply
    },
    {
      path:'/login', // 登录
      name:'ant_login',
      component:ant_login
    },   
    {
      path:'/gongdan', // 添加
      component:gongdan
    },
    {
      path:'/myback', // 修改
      name:'myback',
      component:myback,
     
      children: [
        {
          path: '/mybackuser',
          component: myback_user,
          beforeEnter:(to,from,next)=>{
            var uid = sessionStorage.getItem('uid')
            
           
              axios.get('http://127.0.0.1:8000/yz/?uid='+uid).then(res=>{
                var rs = res.data.data
                if(rs){     
                  next();
                }else{
                  message.info('没有权限')
                }
              })
            
          },
          children:[
        {
            path: '/add',
            component: ant_reg,
            },
     
        {
            path: '/putuser',
            component: putuser
        },{
            path: '/find',
            component: finduser
        },{
          path: '/del',
          component: deluser
        },{
          path: '/add',
          component: ant_reg
        }],
       
      },
  {
    path: '/look',
    component: lookuser,
    beforeEnter:(to,from,next)=>{
        var uid = sessionStorage.getItem('uid')
        
        
          axios.get('http://127.0.0.1:8000/yz/?uid='+uid).then(res=>{
            var rs = res.data.data
            
            if(!rs){
              next()
            }else{
              message.info('没有权限')
            }
          })
        
      }
  },
    {
      path: '/qx',
      component: myqxupdate,
    },
    {
      path:'/gongdans',
      component:mybackgong
    },
    {
      path:'/gongdanadd',
      component:gongdanadd
    },
    {
      path:'/gongdanget',
      component:gongdanget
    }
    ],
  
  }]
})






